<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>时钟</title>
	</head>
	<body>
        <span id="nowTime"></span>
	</body>
	<script type="text/javascript">
	    getLongDate()
	    function dateFilter(a){ //参数值小于10时，在前面补0
	    	return a < 10 ? "0"+a : a
	    }
	    function getLongDate(){
	    	
	    	//获得年月日时分秒
	    	
	        let Ndate = new Date()
	        
	        let year = Ndate.getFullYear()
	        
	        let month =Ndate.getMonth()+1
	        
	        let date = Ndate.getDate()
	        
	        let hour = Ndate.getHours()
	        
	        let minute = Ndate.getMinutes()
	        
	        let second = Ndate.getSeconds()
	        
	        let newDate = dateFilter(year)+"-"+dateFilter(month)+"-"+dateFilter(date)+" "+
	        dateFilter(hour)+":"+dateFilter(minute)+":"+dateFilter(second)
	        
	        
	        //获得星期
	        
	        let day = Ndate.getDay()//当前系统时间中的星期值
	        let weeks = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]
	        let week = weeks[day] //根据星期值，从数组中获取对应的星期字符串
	        
	        document.getElementById("nowTime").innerHTML  = "当前时间： "+newDate+" "+week//显示时间 html,获得标签对象
	        
	        setTimeout(getLongDate,1000) //延迟计时器，使时间动起来
	    }
	    
	</script>
</html>
